//
//  BaseViewController.m
//  NekaPrice
//
//  Created by yu on 2018/6/28.
//  Copyright © 2018年 ma c. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.contentView];
    if (kIsiPad) {
        [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.width.mas_equalTo(kContentView_WIDTH);
            make.centerX.mas_equalTo(self.view.mas_centerX);
        }];
    }else {
        [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.left.right.mas_equalTo(0);
        }];
    }
    
    [self setupNarBar];
    
}



- (void)setupNarBar {
    if (self.navigationController) {//处于导航控制中时,添加自定制的NavBar
        [self.view addSubview:self.customBar];
    }
}

- (CustomeNavigationBar *)customBar {
    if (_customBar == nil) {
        _customBar = [CustomeNavigationBar customeNavigationBar];
        _customBar.delegate = self;
        [_customBar showBackBtn:YES closeBtn:NO shareBtn:NO];
    }
    return _customBar;
}

- (void)hideNavBar {//隐藏自定义的NavBar
    if (self.customBar) {
        [self.customBar setHidden:YES];
    }
}

- (void)setTitle:(NSString *)title {
    [super setTitle:title];
    
    [self.customBar showTitle:title];
    
}


- (void)customeNavigationBar:(CustomeNavigationBar *)bar clickBackBtn:(UIButton *)backBtn {
    if (self.navigationController) {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)customeNavigationBar:(CustomeNavigationBar *)bar clickCloseBtn:(UIButton *)closeBtn {
    
}

- (void)customeNavigationBar:(CustomeNavigationBar *)bar clickShareBtn:(UIButton *)shareBtn {
    
}

- (UIView *)contentView {
    if (_contentView == nil) {
        _contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, K_WIDTH, K_HEIGHT)];
        _contentView.backgroundColor = [UIColor clearColor];
        _contentView.userInteractionEnabled = YES;
    }
    return _contentView;
}






@end
